home *** CD-ROM | disk | FTP | other *** search
- ;==========================================================================
- ; ADDATTR.ASM
- ;
- ; Assembler: Turbo Assembler 1.0 (tasm /ml/t/w2/z addattr;)
- ; C prototype:
- ; void pascal far addattr
- ; (
- ; char far *DestBuf, /* receiving buffer */
- ; char far *SrcBuf, /* text buffer */
- ; char far *AttrList, /* list of attribute bytes */
- ; int ListSize, /* length of AttrList */
- ; int Attr, /* default attribute */
- ; int Flag /* mark attribute changes */
- ; ) ;
- ;
- ; INCON source files and the object and library files created from
- ; them are:
- ; Copyright (c) 1993-94, Richard Zigler.
- ; You may freely distribute unmodified source, object, and library
- ; files, and incorporate them into your own non-commercial software,
- ; provided that this paragraph and the copyright string defined in
- ; INCON.C are included in all copies.
- ;==========================================================================
-
- .model small, pascal
- .code
-
- public ADDATTR
- ADDATTR proc far
- uses si, di, ds, es
-
- arg Flag: word ;mark attribute changes
- arg Attr: word ;default attribute
- arg ListSize: word ;length of AttrList
- arg AttrList: far ptr byte ;list of attributes
- arg SrcBuf: far ptr byte ;text buffer
- arg DestBuf: far ptr byte ;receiving buffer
-
- cld ;do strings low-to-high
- mov cx, [ListSize] ;get list size
- les di, [DestBuf] ;destination buffer
-
- ; For this next to work, AttrList and SrcBuf must be in the same segment.
-
- lds bx, [AttrList] ;attribute list
- lds si, [SrcBuf] ;source buffer
- mov dx, [Flag] ;DL = flag character
- mov ah, byte ptr [Attr] ;default attribute
- jcxz NoAttr ;if no AttrList
- and dl, dl
- jz NoAttr ;if no flag char
- GetChar:
- lodsb ;get character from SrcBuf
- and al, al
- jz Exit ;if end of SrcBuf
- cmp al, dl
- je GotFlag ;if flag character
- stosw ;char/attr => DestBuf
- jmp GetChar
- GotFlag:
- lodsb ;get next character
- mov ah, [bx] ; and next attr byte
- stosw ;char/attr => DestBuf
- inc bx
- loop GetChar ;if at end of AttrList,
- NoAttr: ; fall through
- lodsb ;get character from SrcBuf
- and al, al
- jz Exit ;if end of SrcBuf
- stosw ;char/attr => DestBuf
- jmp NoAttr ;if not end of SrcBuf
- Exit:
- ret ;else done
- ADDATTR endp
- end
-
- ; EOF: ADDATTR.ASM
-
-